﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CRM.Admin.Contracts.Model.Customer;
using KingsSharp.Core.Data.Entity;

namespace CRM.Admin.Services.EntityConfigurations.Customer
{
    public class ProductCfg:EntityConfigurationBase<Product,Guid>
    {
        public ProductCfg()
        {
            Property(t => t.Name).HasMaxLength(80);
            Property(t => t.Consumption).HasPrecision(18, 6);
            Property(t => t.NeedSteelWeight).HasPrecision(18, 2);
            Property(t => t.SaleWeight).HasPrecision(18, 2);
            Property(t => t.UseSteelType).HasMaxLength(200);
            HasRequired(t => t.Customer).WithMany().HasForeignKey(f => f.CustomerId);
        }
    }

    public class ComponentCfg : EntityConfigurationBase<Component, Guid>
    {
        public ComponentCfg()
        {
            HasRequired(t => t.Product).WithMany(l => l.Components).HasForeignKey(f => f.ProductId);
            Property(t => t.DownSize).HasMaxLength(200);
            Property(t => t.Name).HasMaxLength(80);
            Property(t => t.PatternPath).HasMaxLength(2000);
            Property(t => t.Size).HasMaxLength(200);
        }
    }
}
